package com.kuang.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
public class RestFulController {

    //安全

    //http://localhost:8080/SpringMVC_04_controller_war_exploded/add?a=1&b=2
    //restful风格 http://localhost:8080/SpringMVC_04_controller_war_exploded/add/a/b

    //@RequestMapping(value = "/add/{a}/{b}",method = RequestMethod.GET)
    //@RequestMapping(value = "/add/{a}/{b}",method = RequestMethod.delete)
    //@DeleteMapping


    //http://localhost:8080/SpringMVC_04_controller_war_exploded/add/2/3
    //@GetMapping( "/add/{a}/{b}")
    @RequestMapping(value = "/add/{a}/{b}",method = RequestMethod.GET)
    public String test1(@PathVariable int a , @PathVariable int b , Model model){
        int res = a+b;
        model.addAttribute("msg" ,"结果1为"+res );
        return "test";
    }

    @PostMapping( "/add/{a}/{b}")
    public String test2(@PathVariable int a , @PathVariable int b , Model model){
        int res = a+b;
        model.addAttribute("msg" ,"结果2为"+res );
        return "test";
    }

}
